<!DOCTYPE html>
<html class="x-admin-sm">
    
    <head>
        <meta charset="UTF-8">
        <title></title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="/static/css/font.css">
        <link rel="stylesheet" href="/static/css/xadmin.css">
        <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="/static/js/xadmin.js"></script>
    </head>
    
    <body>
        <div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">首页</a>
                <a href="">演示</a>
                <a>
                    <cite>导航元素</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
                <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
            </a>
        </div>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header">
                            <button class="layui-btn" onclick="getUser()">
                                <i class="layui-icon layui-icon-refresh"></i>更新用户数据
                            </button>
                        </div>
                        <div class="layui-card-body ">
                        <table class="layui-table layui-form">
                                <thead>
                                    <tr>
                                        <th>序号</th>
                                        <th>OpenID</th>
                                        <th>昵称</th>
                                        <th>头像</th>
                                        <th>性别</th>
                                        <th>城市</th>
                                        <th>省份</th>
                                        <th>国家</th>
                                        <th>语言</th>
                                        <th>关注时间</th>
                                        <th>更新时间</th>
                                    </tr>
                                </thead>
                                <tbody>
                                {{range $key, $value := $.User}}
                                    <tr>
                                        <td>{{IndexForOne $key $.Paginator.CurrentPage $.Paginator.PageSize}}</td>
                                        <td>{{$value.Openid}}</td>
                                        <td>{{$value.Nickname}}</td>
                                        <td><img width="60px" src="{{$value.Headimgurl}}" /></td>
                                        <td>{{index $.Sex $value.Sex}}</td>
                                        <td>{{$value.City}}</td>
                                        <td>{{$value.Province}}</td>
                                        <td>{{$value.Country}}</td>
                                        <td>{{$value.Language}}</td>
                                        <td>{{TimeStampToTime $value.SubscribeTime}}</td>
                                        <td>{{$value.Created}}</td>
                                    </tr>
                                {{end}}
                                </tbody>
                            </table>
                        </div>
                        <div class="layui-card-body ">
                            <div class="page" id="page">
                                <div>
                                    <span class="current">{{.Paginator.CurrentPage}}</span>
                                    {{if gt .Paginator.CurrentPage 1}}
                                        <a class="prev" href="{{urlfor "wechat.UserController.List"}}?page={{IndexDecrOne $.Paginator.CurrentPage}}&start={{if .Start}}{{.Start}}{{end}}&end={{if .End}}{{.End}}{{end}}&status={{if .Status}}{{.Status}}{{end}}&title={{if .Title}}{{.Title}}{{end}}">上一页</a>
                                    {{end}}
                                    {{if lt .Paginator.CurrentPage .Paginator.TotalPage}}
                                        <a class="next" href="{{urlfor "wechat.UserController.List"}}?page={{IndexAddOne $.Paginator.CurrentPage}}&start={{if .Start}}{{.Start}}{{end}}&end={{if .End}}{{.End}}{{end}}&status={{if .Status}}{{.Status}}{{end}}&title={{if .Title}}{{.Title}}{{end}}">下一页</a>
                                    {{end}}
                                    <span class="num">总 {{.Paginator.TotalPage}} 页</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
    <script>
        function getUser() {
                $.ajax({
                    url: '/wechat/user/get',
                    type: 'get',
                    success: function (data) {
                        if (data.code == 200) {
                            layer.alert(data.msg, {
                                icon: 6
                            }, function () {
                                //var index= parent.layer.getFrameIndex(window.name); //获取当前窗口的name
                                //parent.layer.close(index);
                                window.location.reload();
                            });
                        } else {
                            layer.alert(data.msg, {
                                icon: 5
                            });
                        }

                    }
                });
            }
    </script>
</html>